package com.dog.basics.admin.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.mtkj.CouponFromDto;
import com.dog.basics.bean.vo.admin.mtkj.CouponFromVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtCouponService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 优惠券领用表 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-11-09
 */
@RestController
@RequestMapping("/admin/coupon")
@AllArgsConstructor
public class MtCouponController {

        private final IMtCouponService couponService;

        /**
         * 优惠券领用表查询
         * @param: page
         * @param: fromDto
         * @returns
         * @author hangdy
         * @date: 2020/11/14 15:12
         */
        @ApiOperation(value = "优惠券领用", notes = "admin:coupon:couponPage")
        @GetMapping("/couponPage")
        @PreAuthorize("@pms.hasPermission('admin:coupon:couponPage')")
        public R<IPage<CouponFromVo>> page(PageParam page,CouponFromDto fromDto){
                IPage<CouponFromVo> list = couponService.adimeFindCouponList(page, fromDto);
                return R.ok(list);
        }

        /**
         * 删除优惠券领用
         * @param id
         * @return
         * @author hangdy
         */
        @SysLog("删除优惠券领用")
        @ApiOperation(value = "删除优惠券领用", notes = "admin:coupon:delete")
        @PreAuthorize("@pms.hasPermission('admin:coupon:delete')")
        @ApiImplicitParam(value = "优惠券Id", name = "id", dataType = "Long", required = true)
        @DeleteMapping("/delete/{id}")
        public R<Boolean> delete(@PathVariable("id") Long id) {
                return R.ok(couponService.adminDeleteById(id));
        }

}
